ABC250 C - Adjacent Swaps
提出
code: python
n, q = map(int, input().split())
# 1 5 2 9 6 6
# 1 2 3 4 5 6 7 8 9 10
# 2 1 3 4 5 6 7 8 9 10
# 2 1 3 4 6 5 7 8 9 10
# 1 2 3 4 6 5 7 8 9 10
# 1 2 3 4 6 5 7 8 10 9
# 1 2 3 4 5 6 7 8 10 9
# 1 2 3 4 5 7 6 8 10 9
# 右側 or 左側と入れ替え = +1 or -1
for i in x:
else:
else:
target = ans.index(i)
else:
print(*ans, sep=" ")
解答
code: python
n, q = map(int, input().split())
# 整数 j が書かれているボールが左から何番目かを表す変数 posj for v in x:
# print(ans == pos) True
p1 = p0
if (p0 != n):
p1 += 1 # 右隣
else:
p1 -= 1 # 左隣
# pos を ans に追従させる
ans.pop(0)
print(*ans, sep=" ")
メモ
提出
code: python
n, q = map(int, input().split())
# O(NQ)
for v in x:
idx = ball.index(v)
if idx != n-1:
else:
for v in ball:
print(v, end=" ")